<!DOCTYPE html>
<html lang="en" xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>keyevent</title>

</head>
<body>

<div id="app">
    <h2>{{num}}</h2>
    <count :num="num" @inc="increment" @dec="decrement"></count>
</div>
</body>
<script src="../node_modules/vue/dist/vue.js"></script>
<script>
  Vue.component("count",{
      template:`<div>
        <button @click="plus">+</button>
        <button @click="reduce">-</button>
</div>`,
      methods:{
          plus(){
              this.$emit("inc");
          },
          reduce(){
              this.$emit("dec");
          }
      }
  })


    let vm = new Vue({
        el: "#app",
        data:{
         num:0
        },
        methods:{
            increment(){
                this.num++;
            },
            decrement(){
                this.num--;
            }
        }
    })
</script>
</html>